<!--
  用户信息
  props：
    userName string 用户名称
    headUrl string 头像地址
-->
<template>
  <div class="user-wrapper">
    <div class="head-portrait">
      <img :src="headUrl" alt="head">
    </div>
    <div class="user-info">
      <div class="name">
        <span>{{userName}}，欢迎您！</span>
      </div>
      <div class="date">
        <span>{{date}}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "qm-user-info",
  props: {
    userName: {
      type: String,
      default: "陈广创"
    },
    headUrl: {
      type: String,
      default: require("/static/user.png")
    }
  },
  data() {
    return {
      date: null
    }
  },
  created() {
    let date = new Date();
    const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
    let text = date.toLocaleDateString(undefined, options);
    this.date = text.replace(/['年'|'月']/g, "-").split("日").reverse().join(" ");
  }
}
</script>

<style lang="less" scoped>
.user-wrapper {
  display: flex;
  align-items: center;
  .head-portrait {
    margin-right: calc(30px * var(--ratio));
    width: calc(100px * var(--ratio));
    height: calc(100px * var(--ratio));
    background-color: #fff;
    border: calc(5px * var(--ratio)) solid #FFFFFF;
    box-shadow: 0 calc(7px * var(--ratio)) calc(18px * var(--ratio)) 0 #094291;
    border-radius: 50%;
    box-sizing: content-box;

    img {
      width: 100%;
    }
  }
  .user-info {
    .name {
      margin-bottom: calc(17px * var(--ratio));
      font-size: calc(42px * var(--ratio));
      color: #fff;
      font-weight: bold;
      line-height: 1;
    }
    .date {
      font-size: var(--font-size-subcontent);
      color: #fff;
      line-height: 1;
    }
  }
}
</style>
